﻿using UnityEngine;
using System.Collections;

// The edge of a cell
public abstract class MazeCellEdge : MonoBehaviour {

	// The cells that border this edge
	public MazeCell cell, otherCell;
	// The direction of this edge relative to the first cell.
	public MazeDirection direction;

	// Initialize the edge.
	public void Initialize (MazeCell cell, MazeCell otherCell, MazeDirection direction) {
		this.cell = cell;
		this.otherCell = otherCell;
		this.direction = direction;
		cell.SetEdge (direction, this);
		transform.parent = cell.transform;
		transform.localPosition = Vector3.zero;
		transform.localRotation = direction.ToRotation ();
	}

	// Is this a wall?
	public abstract bool isWall();

	// Return the two cells in an array.
	public MazeCell[] cells() {
		MazeCell[] ourCells = new MazeCell[2];
		ourCells [0] = cell;
		ourCells[1] = otherCell; 
		return ourCells;
	}

}
